#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m;
    cin >> n >> m;

    vector<vector<int>> dis(n + 1, vector<int>(n + 1, 0x3f3f3f3f));
    map<pair<int, int>, vector<pair<int, int>>> mp;
    priority_queue<array<int, 3>, vector<array<int, 3>>, greater<array<int, 3>>> q;
    
    q.push({0, n, n});
    dis[n][n] = 0;

    for (int i = 1; i <= m; i++) {
        int x, y, xx, yy;
        cin >> x >> y >> xx >> yy;
        mp[{x, y}].emplace_back(xx, yy);
        mp[{xx, yy}].emplace_back(x, y);
    }

    while (!q.empty()) {
        auto [d, x, y] = q.top();
        q.pop();

        if (dis[x][y] < d) continue;  

        if (mp.count({x, y})) {
            for (auto [nx, ny] : mp[{x, y}]) {
                if (dis[nx][ny] > d + 1) {
                    dis[nx][ny] = d + 1;
                    q.push({d + 1, nx, ny});
                }
            }
        }

        for (int i = 0; i < 4; i++) {
            int nx = x + dx[i], ny = y + dy[i];
            if (nx < 1 || ny < 1 || nx > n || ny > n) continue;
            if (dis[nx][ny] > d + 1) {
                dis[nx][ny] = d + 1;
                q.push({d + 1, nx, ny});
            }
        }
    }

    i64 sum = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            sum += dis[i][j];
        }
    }

    printf("%.2f\n", sum * 1.0 / (n * n));
    return 0;
}